package com.cty.service.impl;

import com.cty.mapper.PictureMapper;
import com.cty.pojo.Picture;
import com.cty.service.PictureService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: com.cty
 * @Date: 2020/3/26 21:59
 * @Description:
 * @version: 1.0
 */
@Service
public class PictureServiceImpl implements PictureService {
    Logger log = Logger.getLogger(PictureServiceImpl.class);

    @Value("${management.url}")
    private String path;

    @Resource
    private PictureMapper pictureMapper;

    @Override
    public void insPictureService(Picture picture) {
        this.pictureMapper.insPicture(picture);
    }

    @Override
    public List<Picture> selAllService() {
        List<Picture> pictures = this.pictureMapper.selAll();
        for(Picture picture:pictures){
            picture.setPath(path+picture.getPath());
        }
        log.info("已查询所有图片信息："+pictures);
        return pictures;
    }

    @Override
    public void delPictureService(int id) {
        this.pictureMapper.delPicture(id);
    }
}
